package org.jackysoft.google.collection;

import org.jackysoft.entity.TreeNode;
import org.jackysoft.entity.WebApplication;

public class TreeNodeZtreeFunction extends
		AbstractZTreeFunction<TreeNode, ZTreeNode> {

	private boolean nocheck=true;
	
	
	public TreeNodeZtreeFunction(boolean nocheck) {
		this.nocheck = nocheck;
	}
	
	public TreeNodeZtreeFunction(){}


	@Override
	public ZTreeNode apply(TreeNode from) {
		WebApplication  webapp = from.getWebapp();		
		ZTreeNode zn = new ZTreeNode();
		zn.setId(from.getId()+"");
		zn.setName(from.getDescription());
		zn.setNocheck(nocheck);
		zn.setIsParent((!from.isLeaf())+"");
		zn.setSort(from.getSort());
		zn.setHref(from.getIdentifier());	
		zn.setVisiable(from.isVisiable());
		zn.attr("webappId", webapp==null?"local":webapp.getId());
		zn.attr("prefix", webapp==null?"":webapp.toString());
		zn.attr("catalog", from.getCatalog());
		return zn;
	}

}
